<div class="page">
	<div class="pageContent">
		<form id="navigationAddChildren" type="put" action="{entity}/{entity_id}" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
			<div class="pageFormContent" layoutH="57" action="{entity}/{entity_id}" bind="bindEntityInfo" entity_id="{entity_id}" category_id="{category_id}" entity="{entity}" sign="{sign}">
				<fieldset>
					<legend>基本信息</legend>
					<div class="unit">
						<label>标题：</label> <input name="title" class="required" type="text" size="30" value="${title}" focus=true />
					</div>
					<!-- 屏蔽文件上传，内容编辑和url填写，需要时可以放开隐藏使用-->
					<div class="unit" style="display: none">
						<label>URL：</label> <input name="url" class="url" type="text" size="30" value="${url}" />
					</div>
					<div class="unit" style="display: none">
						<label>图片：</label> <span> <img name="picture" path="${small}" oldpath="" /> <input name="file_id" type="hidden" size="30" value="" /> <a href="javascript:;"
							url="multiupload/multiupload.html?ext=图片文件(*.jpg;*.gif;*.png;*.bmp;*.jpeg)&count=1&size=500 KB" target="dialog" rel="multiupload" iframe="true" mask="true" width="400"
							height="300" callback="uploadEntityPic">上传文件</a>
						</span>
					</div>
					<p>
						<span style="margin-left: 5px">可编辑： <input type="radio" name="islock" value=0 /></span> <span style="margin-left: 25px">锁定：<input type="radio" name="islock" value=1 /></span>
					</p>
					<p>
						<span style="margin-left: 5px">不指派： </span><span><input type="radio" name="ontop" value=0 onclick="checkRole()" /></span> <span style="margin-left: 25px">指派： </span><span><input
							type="radio" name="ontop" value=1 onclick="checkRole()" /></span> <input type="hidden" name="oldOntopValue" />
					</p>
					<div class="textareaBar" style="display: none">
						<label>内容：</label>
						<textarea class="editor"
							tools="{tools:'mfull',upBtnText:'上传',upImgUrl:'/services/file',upImgExt:'jpg,jpeg,gif,png',upFlashUrl:'/services/file',upFlvUrl:'/services/file',upMediaUrl:'/services/file',upMediaExt:'wmv,avi,wma'}"
							name="content" rows="5" style="width: 100%;">${content}</textarea>
					</div>
				</fieldset>
				<input type="hidden" id="value" name="value" />
			</div>
			<div class="formBar">
				<ul>
					<li><div class="buttonActive">
							<div class="buttonContent">
								<button type="submit" class="ok" onclick="setAttributeValue();">修改</button>
							</div>
						</div></li>
					<li><div class="button">
							<div class="buttonContent">
								<button type="button" class="close">取消</button>
							</div>
						</div></li>
				</ul>
			</div>
		</form>
	</div>
</div>
<script>
	function uploadEntityPic(msg, $dom) {
		var content = $dom.parents(".pageFormContent");
		$("img[name=picture]", content).attr("src", msg[0].small).click(function() {
			var win = window.open("about:blank");
			win.document.body.innerHTML = '<img src="'+msg[0].origin+'" />';
		});//.attr("oldpath",msg[0].origin);
		$("input[name=file_id]", content).val(msg[0].file_id);
		$("input[name=title]", content).focus();
		//alert($("input[name=file_id]",content).val());
		//alert($("img[name=picture]",content).attr("src"));
	}
	//自定义绑定方法
	//data-entity信息
	//$dom-pageFormContent对应的jqueryDOM对象
	function bindEntityInfo(data, $dom) {
		//在此处写绑定方法
		$("input[name=title]", $dom).val(data.title).focus();
		$("input[name=url]", $dom).val(data.url);
		$("input[name=file_id]", $dom).val(data.file_id);
		$("img[name=picture]", $dom).attr("src", data.small);
		$("textarea[name=content]", $dom).val(data.content);
		$("input[name=islock][value=" + data.islock + "]").attr("checked", "checked");
		$("input[name=ontop][value=" + data.ontop + "]").attr("checked", "checked");

		//用于判断指派（置顶）权限  车管所特有
		$("input[name=oldOntopValue]").val(data.ontop);

		var signStr = $dom.attr("entity");
		if (signStr != "document") {//车管所项目中，只有项目管理才有指派
			$("div[name=ontopDiv]").hide();
		}
		bindExtField($dom, data, "update");
	}

	/**
	 * 组装纵向扩展属性(datum) ，将扩展属性的值以json格式保存在value对象中
	 */
	function setAttributeValue() {
		var submitValue = "[";

		//组装提交到后台的value数据
		var valArr = $("input[name^='value_id_']");
		for ( var i = 0; i < valArr.length; i++) {
			var att = valArr[i];
			var valueId = $(att).attr("valueId");
			var updateValue = $(att).attr("value");
			submitValue = submitValue + "{value_id:'" + valueId + "',value:'" + updateValue + "'},";
		}
		submitValue = submitValue.substr(0, submitValue.lastIndexOf(",")) + "]";
		//$("#value").val(submitValue);
	}

	//验证置顶（指派）权限
	function checkRole() {
		var v = $("input[name=oldOntopValue]").val();
		var roleId = DWZ.user.role;
		if (parseInt(roleId) < 7) {
			alertMsg.error("没有指派权限");
			$("input[name=ontop][value=" + v + "]").attr("checked", "checked");
			return false;
		}
	}
</script>